<?php
//====================================================================
if(!empty($_GET['tid'])&&is_array($_GET['tid']))
	$tid=implode(',',$_GET['tid']);
elseif(!empty($_GET['tid']))
	$tid=$_GET['tid'];
if(!empty($tid))
{
	$sql="select id,pname from ".PRO." WHERE id in ($tid)";
	$db->query($sql);
	$res=$db->getRows();
	$tpl->assign("res",$res);
	$tpl->assign("tid",$tid);
}
if(!empty($_POST['submit']))
{	
	session_start();
	if(strtolower($_POST['yzm'])!=strtolower($_SESSION['auth']))
	{
		if(!empty($_POST['isflow']))
			msg("api/mail_box.php?uid=".$_POST['toid']."&type=3");
		else
			msg("shop.php?action=mail&uid=$_GET[uid]&type=3");
	}
	else
	{
		include_once("includes/plugin_msg_class.php");
		$msg=new msg();
		$res=$msg->send_email();
		if(!empty($_POST['isflow']))
		{
			if($res)
				msg("api/mail_box.php?uid=".$_POST['toid']."&type=1");
			else
				msg("api/mail_box.php?uid=".$_POST['toid']."&type=2");
		}
		elseif($res)
			msg("shop.php?action=mail&uid=$_GET[uid]&type=1");
		else
			msg("shop.php?action=mail&uid=$_GET[uid]&type=2");
	}
}
$tpl->assign("country",country_list());
//====================================================================
$tpl->assign("lang",$lang);
$tpl->assign("config",$config);
$tpl->assign("com",$company);
$output=tplfetch("space_send_mail.htm",$flag);
?>